//Object.create创建一个空对象


function myNew(fn, ...args) {
    const obj = Object.create(fn.prototype)
    const result = fn.apply(obj, args)
    return typeof result === 'object' ? result : obj
}



function myNew1(fn,...args){
    const obj = {a:1}
    obj.__proto__ = fn.prototype
    const result = fn.call(obj,...args)
    return result instanceof Object ? result : obj

}
function test(name,age){
    console.log(this,'this')
    this.name = name
    this.age = age
}
const data = myNew1(test,'张三','18')
console.log(data,'data')